//
//  AboutViewController.m
//  SportSocial
//
//  Created by 韩方宇 on 15/2/12.
//  Copyright (c) 2015年 yull. All rights reserved.
//

#import "AboutViewController.h"
#import "NSString+Size.h"

@interface AboutViewController ()

@property (nonatomic, strong) UIScrollView *aboutScrollView;

@property (nonatomic, strong) UILabel *detailLabel;

@end

@implementation AboutViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self createSubView];
    
    [self setDetailLabelText];
}

- (void)createSubView
{
    self.navigationItem.title = @"关于";
    
    self.view.backgroundColor = RGB(246, 246, 246);
    
    [self addCommonBackButton];
    
    CGRect rect = CGRectMake(0, 0, self.view.width, self.view.height - Navibar_Height);
    self.aboutScrollView = [[UIScrollView alloc] initWithFrame:rect];
    [self.view addSubview:self.aboutScrollView];
    
    rect = CGRectMake(0, 30, 80, 80);
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:rect];
    imageView.image = [UIImage imageNamed:@"icon"];
    imageView.centerX = self.aboutScrollView.width/2;
    [self.aboutScrollView addSubview:imageView];
    
    rect = CGRectMake(0, imageView.bottom + 10, self.aboutScrollView.width, 50);
    UILabel *versionlabel = [[UILabel alloc] initWithFrame:rect];
    versionlabel.textAlignment = NSTextAlignmentCenter;
    versionlabel.font = [UIFont systemFontOfSize:18.0f];
    versionlabel.textColor = [UIColor blackColor];
    versionlabel.numberOfLines = 2;
    versionlabel.text =[NSString stringWithFormat:@"GO青春\nV%@", [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString*)kCFBundleVersionKey]];
    [self.aboutScrollView addSubview:versionlabel];
    
    rect = CGRectMake(10, versionlabel.bottom + 20, self.aboutScrollView.width - 20, 40);
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:rect];
    titleLabel.backgroundColor = [UIColor whiteColor];
    titleLabel.textColor = RGB(146, 146, 146);
    titleLabel.text = [NSString stringWithFormat:@"  V%@功能简介", [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString*)kCFBundleVersionKey]];
    titleLabel.font = [UIFont systemFontOfSize:16.0f];
    [self.aboutScrollView addSubview:titleLabel];
    
    rect = CGRectMake(10, titleLabel.bottom + 20, self.aboutScrollView.width - 20, 0);
    self.detailLabel = [[UILabel alloc] initWithFrame:rect];
    self.detailLabel.backgroundColor = [UIColor clearColor];
    self.detailLabel.textColor = RGB(146, 146, 146);
    self.detailLabel.font = [UIFont systemFontOfSize:14.0f];
    self.detailLabel.numberOfLines = 0;
    [self.aboutScrollView addSubview:self.detailLabel];
}

- (void)setDetailLabelText
{
    NSString *text = @"\tGO青春是一款国内火热的体育交友应用。\n\t在城市里进行一些体育项目和健身，经常会遇到找不到场地和玩伴的现象。GO青春因此孕育而生，为帮助体育爱好者找到共同体育爱好的人在附近的场地里可以一起进行体育项目，也鼓励大家在线上和线下对体育赛事的关注。\n\tGO青春的宗旨是想制造一个青春、有活力和积极向上的体育氛围，去供应体育爱好者互动的平台，也支持一些体育项目新手们加入。\n\n功能简介\n\t附近的人/俱乐部，结识你周围的体育爱好者，并可以加入你所喜好的俱乐部参加俱乐部活动。\n\t附近的场地，帮助了解离你所在位置最近的场地信息。\n\t体育新闻和赛事，为你第一时间搜集体育赛事新闻头条。\n\t跑步计算器，GPS定位你所跑步的距离，并估算你的消耗的卡路里。\n\t运动小计划，便捷式运动计划表使你的运动计划更加清楚明了。\n";
    self.detailLabel.text = text;
    
    CGSize constrainedSize = CGSizeMake(self.detailLabel.width, CGFLOAT_MAX);
    CGSize labelSize = [text getSizeWithFont:self.detailLabel.font constrainedSize:constrainedSize];
    self.detailLabel.height = labelSize.height;
    
    self.aboutScrollView.contentSize = CGSizeMake(self.view.width, self.detailLabel.bottom + 30);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
